import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsEmail, IsMobilePhone } from 'class-validator';

export class CreateUserDto {
  @ApiProperty({
    type: String,
    description: '用户名',
    default: '小明',
  })
  @IsNotEmpty({ message: '用户名不能为空' })
  readonly username: string;

  @ApiProperty({
    type: String,
    description: '密码',
    default: '666666',
  })
  @IsNotEmpty({ message: '密码不能为空' })
  password: string;

  @ApiPropertyOptional({
    type: String,
    description: '邮箱',
    default: 'email@email.com',
  })
  @IsEmail({}, { message: '请输入正确的邮箱地址' })
  readonly email?: string;

  @ApiPropertyOptional({
    type: Number,
    description: '手机号',
    default: 188888888888,
  })
  @IsMobilePhone('zh-CN', {}, { message: '请输入正确的手机号' })
  readonly phone?: number;

  public salt?: string;

  public id?: string;
}
